Skip to content

feat(nextjs): Remove client source maps with the webpack plugin's deleteSourcemapsAfterUpload - #26337

Draft
timfish wants to merge 1 commit into
developfrom
feat/nextjs-delete-sourcemaps-after-upload
Draft

timfish wants to merge 1 commit into
developfrom
feat/nextjs-delete-sourcemaps-after-upload

Conversation

@timfish

@timfish timfish commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

The Next.js SDK deleted client source maps on webpack with its own static/**/*.map globs. This PR hands that job to the bundler plugin's deleteSourcemapsAfterUpload: the client compiler passes the SDK option, with true as the default when sourcemaps.disable is not set, and the server and edge compilers pass false, so server maps stay as before. A user's own filesToDeleteAfterUpload is still passed through and replaces the SDK's deletion, as today. Turbopack and the useRunAfterProductionCompileHook path keep their globs.

Without the internal sdkEnabledSourceMaps flag from #26281, the plugin removes every map of a build only when it turned the maps on itself. Next.js turns them on, so the plugin would remove only the maps of uploaded chunks, and Next's narrow upload globs would leave main-*, framework-*, shared chunk and CSS maps behind. The client compiler therefore passes that flag whenever it deletes. The plugin then removes every JS and CSS map of the client build, with or without an upload, including maps the user turned on with productionBrowserSourceMaps.

There are two differences you can see. First, for maps the user turned on as visible maps, the plugin switches to hidden maps, so the sourceMappingURL comments that pointed at the deleted files are gone too. Second, client maps are no longer written to disk and then deleted in afterEmit, so a plugin that reads them from disk after emit finds none. The E2E apps now include CSS and also check for sourceMappingURL comments.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 40b436b (PR test merge using develop at 9279303)

Against: 9279303 (develop) · base run #66015

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.1 kB - -
@sentry/browser - with treeshaking flags 28.3 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.2 kB - -
@sentry/browser (incl. Tracing) 52.28 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.29 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.25 kB - -
@sentry/browser (incl. Tracing, Replay) 92.82 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.6 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.21 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.6 kB - -
@sentry/browser (incl. Feedback) 47.73 kB - -
@sentry/browser (incl. sendFeedback) 30.69 kB - -
@sentry/browser (incl. FeedbackAsync) 35.69 kB - -
@sentry/browser (incl. Metrics) 31.43 kB - -
@sentry/browser (incl. Logs) 31.71 kB - -
@sentry/browser (incl. Metrics & Logs) 32.37 kB - -
@sentry/react 32.11 kB - -
@sentry/react (incl. Tracing) 54.95 kB - -
@sentry/vue 38.3 kB - -
@sentry/vue (incl. Tracing) 55.24 kB - -
@sentry/svelte 30.12 kB - -
@sentry/remix (Remix 3 client bundle) 58.06 kB - -
CDN Bundle 31.87 kB - -
CDN Bundle (incl. Tracing) 52.7 kB - -
CDN Bundle (incl. Logs, Metrics) 34.67 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.26 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.7 kB - -
CDN Bundle (incl. Tracing, Replay) 90.72 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.09 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.69 kB - -
CDN Bundle - uncompressed 92.98 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.45 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.33 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.08 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 231.43 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.6 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 283.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.39 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.01 kB - -
@sentry/nextjs (client) 58.34 kB - -
@sentry/sveltekit (client) 53.46 kB - -
@sentry/core/server 44.57 kB - -
@sentry/core/browser 13.99 kB - -
@sentry/node 149.54 kB -0.01% -4 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.3 kB - -
@sentry/node - without tracing 88.47 kB -0.01% -8 B 🔽
@sentry/node - without channel injection 138.5 kB -0.01% -3 B 🔽
@sentry/aws-serverless 97.39 kB -0.01% -8 B 🔽
@sentry/cloudflare (withSentry) - minified 204.55 kB - -
@sentry/cloudflare (withSentry) 474.76 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 229.86 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 1 not successful, 9 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E nextjs-16-cacheComponents (cloudflare) Test (optional) Failing after 10m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 2m Details

@timfish
timfish force-pushed the feat/nextjs-delete-sourcemaps-after-upload branch from 2de614c to b5b1f4d Compare November 13, 2026 11:35
Base automatically changed from feat/bundler-plugins-delete-without-upload to develop November 13, 2026 13:49
…leteSourcemapsAfterUpload`

The webpack client compiler no longer gets the `static/**/*.map` globs. It passes the SDK's `deleteSourcemapsAfterUpload` to the plugin instead, with `true` as the default. A user's own `filesToDeleteAfterUpload` is passed through and replaces this deletion, as before, so the plugin then gets `false`. Whenever the client deletes, it also passes `sdkEnabledSourceMaps`, so the plugin removes every JS and CSS map of the client build: those the SDK turned on and those the user turned on with `productionBrowserSourceMaps` or `devtool`, also of chunks outside the upload globs and also when no upload runs. Server and edge compilers get `false`, so their maps stay as before. Turbopack and `useRunAfterProductionCompileHook` builds keep the globs.

The E2E apps now import a CSS file and also check `.next/static` for `sourceMappingURL` comments in JS and CSS.
@timfish
timfish force-pushed the feat/nextjs-delete-sourcemaps-after-upload branch from b5b1f4d to 7af6213 Compare November 13, 2026 13:53

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant